{% extends "king_admin/table_index.html" %}
{% load tags %}
<!-- css Jquery里面有默认属性!important作用是优先height: 300px;使用 -->
{% block extra-css-resources %}
    <style type="text/css">
        .filter-select-box{
            width: 100%;
            height: 150px !important;
            border-radius:4px;
        }
    </style>
{% endblock %}

{% block container %}
{#    {{ form_obj }}#}
    <form class="form-horizontal" role="form" method="post" onsubmit="return SelectAllChosenData()">
        {% csrf_token %}
        <span style="color:red">{{ form_obj.errors }}</span>
        {% for field in form_obj %}
          <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label" style="font-weight: normal">
                {% if field.field.required %} <!-- 判断是否是必填 -->
                    <b>{{ field.label }}</b>
                {% else %}
                    {{ field.label }}
                {% endif %}
            </label>
            <div class="col-sm-6">
                {{ field }}
                <span style="color: #aaaaaa">{{ field.help_text }}</span>
                <span style="color: red">{{ field.errors.as_text }}</span>
            </div>
          </div>
        {% endfor %}
        <!-- 自行定义前端禁止或后端禁止开关,前端可以用 if not 不过会出现save不显示的bug -->
{#        {% if not admin_class.readonly_table %}  #}
        <div class="form-group">
            <div class="col-md-10 col-sm-10">
                {% block obj_delete %}
                    <a class="btn btn-danger" href="{% url 'obj_delete' app_name table_name form_obj.instance.id %}">Delete</a>
                {% endblock %}
                <button type="submit" class="btn btn-info pull-right">Save</button>
            </div>
        </div>
{#        {% endif %}  #}
    </form>
    <script>
        function SelectAllChosenData(){
            // remove all disabled attrs
            $("form").find("[disabled]").removeAttr("disabled");
            return true;
        }
    </script>
{% endblock %}


















